home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Font Fun / DropShadow / DropShadow.cs next >
Encoding:
Text File  |  2001-01-15  |  1.1 KB  |  35 lines

  1. //-----------------------------------------
  2. // DropShadow.cs ⌐ 2001 by Charles Petzold
  3. //-----------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class DropShadow: FontMenuForm
  9. {
  10.      const int iOffset = 10;   // Approximately 1/10 inch (exactly on printer)
  11.  
  12.      public new static void Main()
  13.      {
  14.           Application.Run(new DropShadow());
  15.      }
  16.      public DropShadow()
  17.      {
  18.           Text = "Drop Shadow";
  19.           Width *= 2;
  20.           strText = "Shadow";
  21.           font = new Font("Times New Roman", 108);
  22.      }
  23.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  24.      {
  25.           SizeF sizef = grfx.MeasureString(strText, font);
  26.           float x     = (cx - sizef.Width) / 2;
  27.           float y     = (cy - sizef.Height) / 2;
  28.  
  29.           grfx.Clear(Color.White);
  30.           grfx.DrawString(strText, font, Brushes.Gray, x, y);
  31.           grfx.DrawString(strText, font, Brushes.Black, x - iOffset, 
  32.                                                         y - iOffset);
  33.      }
  34. }
  35.